/*JAG
 * eventually replace this module with a faster algorthm, since the data is sorted.
 * */
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function dataSuggestions() {
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
dataSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    
    if (sTextboxValue.length > 0){
    
        //search for matching data
        for (var i=0; i < this.data.length; i++) { 
			temp = this.data[i];
			temp = temp.toLowerCase();
			input = sTextboxValue.toLowerCase();
            if (temp.indexOf(input) == 0) {
                aSuggestions.push(this.data[i]);
            } 
        }
    }

    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};
